import java.util.*;

class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode(int x) { val = x; }
}
public class project {
    public List<String> removeAnagrams(String[] words) {
        List<String> list=new LinkedList<>();
        String prev="";
        for(int i=0;i<words.length;i++){
            char[] chs=words[i].toCharArray();
            Arrays.sort(chs);
            String str=String.valueOf(chs);
            if(i>0&&str.equals(prev)){
                continue;
            }
            list.add(words[i]);
            prev=str;
        }
        return list;
    }













    public int divisorSubstrings(int num, int k) {
        int count=0;
        String s=num+"";
        for(int i=0;i<=s.length()-k;i++){
            int cur=Integer.parseInt(s.substring(i,i+k));
            if(cur!=0&&num%cur==0){
                count++;
            }
        }
        return count;
    }

















    TreeNode node;
    TreeNode cur;
    public TreeNode inorderSuccessor(TreeNode root, TreeNode p) {
        dfs(root,p);
        return node;
    }

    private void dfs(TreeNode root, TreeNode p) {
        if(root==null){
            return;
        }
        dfs(root.left,p);
        if(cur==p){
            node=cur;
        }
        cur=root;
        dfs(root.right,p);
    }
}
